import { MergeConfigType, MergeConfigItem } from '@/components/FormPro/props';
import { getEditOrDetailConfig } from '@/components/FormPro/util';
import Upload from '@/components/Upload/index.vue';

export const getFormFileds = (type: MergeConfigType) => {
  const formBaseList: MergeConfigItem[] = [
    {
      label: '任务结束表显里程',
      filed: 'end_mileage',
      props: {
        col: {
          span: 24,
        },
      },
      edit: {
        props: {
          component: {
            placeholder: '请填写 任务结束表显里程',
            min: 0,
          },
          formItem: ({ formModel }) => {
            if (formModel.billType === 'biaoxian') {
              return {
                rules: [
                  {
                    required: true,
                    trigger: 'change',
                    message: '请填写 任务结束表显里程',
                  },
                ],
              };
            }
            return {};
          },
        },
        component: 'a-input-number',
      },
    },
    {
      label: '任务结束附件',
      filed: 'end_file',
      props: {
        col: {
          span: 24,
        },
      },
      edit: {
        props: {
          component: {
            limit: 1,
          },
          formItem: ({ formModel }) => {
            if (formModel.billType === 'biaoxian') {
              return {
                rules: [
                  {
                    required: true,
                    trigger: 'change',
                    message: '请上传 附件',
                  },
                ],
              };
            }
            return {};
          },
        },
        component: Upload,
      },
    },

    {
      label: '其他费用',
      filed: 'suspended_expenses',
      props: {
        col: {
          span: 24,
        },
      },
      edit: {
        props: {
          component: {
            placeholder: '请填写 其他费用',
            min: 0,
          },
        },
        component: 'a-input-number',
      },
    },
    {
      label: '备注',
      filed: 'remark',
      props: {
        col: {
          span: 24,
        },
      },
      edit: {
        props: {
          component: {
            placeholder: '请填写 备注',
            min: 0,
          },
        },
        component: 'a-textarea',
      },
    },
  ];

  return getEditOrDetailConfig(formBaseList, type);
};
